//
//  TravelTableViewCell.m
//  Community
//
//  Created by YaSha_Tom on 2018/12/21.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "TravelTableViewCell.h"
@interface TravelTableViewCell ()
@property (nonatomic,strong)UIImageView *headImageView;
@property (nonatomic,strong)UILabel *nameLabel;
//@property (nonatomic,strong)UILabel *timeLabel;
@property (nonatomic,strong)UILabel *contentLabel;
@end

@implementation TravelTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
-  (void)initUI {
    self.headImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"head_1"]];
    [self addSubview:self.headImageView];
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(40*rateh, 40*rateh));
        make.left.mas_equalTo(self.mas_left).offset(10);
        make.top.mas_equalTo(self.mas_top).offset(10*rateh);
    }];
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.text = @"张三";
    [self addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(Width/2, 20*rateh));
        make.left.mas_equalTo(self.headImageView.mas_right).offset(10);
        make.top.mas_equalTo(self.headImageView.mas_top).offset(10);
    }];
    self.timeLabel = [[UILabel alloc]init];
    self.timeLabel.text  = @"2018-12-21";
    self.timeLabel.font = [UIFont systemFontOfSize:14];
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(Width/2, 20*rateh));
        make.right.mas_equalTo(self.mas_right).offset(-45*rateh);
        make.top.mas_equalTo(self.mas_top).offset(18);
//        make.centerY.mas_equalTo(self.nameLabel);
    }];
    
    self.moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.moreButton setImageEdgeInsets:UIEdgeInsetsMake(11*rateh, 18*rateh, 11*rateh, 19*rateh)];
    [self addSubview:self.moreButton];
    [self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(40*rateh, 40*rateh));
        make.right.mas_equalTo(self.mas_right).offset(-5);
        make.centerY.mas_equalTo(self.headImageView);
    }];
    
    self.contentLabel = [[UILabel alloc]init];
    self.contentLabel.text = @"卡佛而我问平凡人是分配喷雾瓶人发怕怕的瓦片去安排的迫切任务鹏爱普生的怕我的安全阿配送网大全iOS哦都是豆腐皮水电费拍摄地扶贫拍摄地扶贫是平水电费的说法是【是的冯绍峰【水电费水电费【孙菲菲";
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.right.mas_equalTo(self.mas_right).offset(-15); make.top.mas_equalTo(self.headImageView.mas_bottom).offset(5);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-10);
    }];
    
}
- (void)setTravelData:(BmobObject *)model {
    self.nameLabel.text  = [model objectForKey:@"name"];
    self.contentLabel.text = [model objectForKey:@"content"];
    self.timeLabel.text = [[model objectForKey:@"updatedAt"] substringToIndex:10];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
